﻿using System;
using System.Xml;
using System.IO;
using Microsoft.Xna.Framework.Content;
using System.Diagnostics;

namespace BaseThing.Game
{
    class Config
    {
        public static ContentManager content;
        public static int SCREEN_WIDTH = 800; //Default Width
        public static int SCREEN_HEIGHT= 600; //Default Height
        public static bool FULL_SCREEN = false; //Is Full Screen
        public static bool SHOW_MOUSE = false; //Show Mouse
        public static bool DEBUG_PHYSICS = true; //Debug Physics
        

        public static void Initialize() {}
        public static ContentManager GetContentManager() { return content; }


        public static void LoadFromXML(String xmlFilePath)
        {

            XmlTextReader XmlRdr = new XmlTextReader(xmlFilePath);

            while (XmlRdr.Read())
            {
                if (XmlRdr.NodeType == XmlNodeType.Element)
                {
                    try
                    {
                        switch (XmlRdr.Name)
                        {
                            case "Screen":
                                //LMI.Name = XmlRdr.ReadElementString();
                                Config.SCREEN_WIDTH = int.Parse(XmlRdr.GetAttribute("width"));
                                Config.SCREEN_HEIGHT = int.Parse(XmlRdr.GetAttribute("height"));
                                Config.FULL_SCREEN = bool.Parse(XmlRdr.GetAttribute("fullscreen"));
                                Config.SHOW_MOUSE = bool.Parse(XmlRdr.GetAttribute("showMouse"));

                                break;
                            case "Physics":
                                Config.DEBUG_PHYSICS = bool.Parse(XmlRdr.GetAttribute("debug"));
                            break;
                        }
                    }
                    catch (Exception error)
                    {
                        Trace.WriteLine("Error al cargar el XML -> " + error.TargetSite + " : " + error.Message);
                    }
                }
            }

        }
    }
}


